package com.xjrsoft.module.erpModel.caseErpSale.utils;

import cn.hutool.core.util.RandomUtil;
import com.xjrsoft.module.erpModel.caseErpSale.vo.CollectionVo;
import com.xjrsoft.module.erpModel.caseErpSale.vo.InvoiceVo;
import com.xjrsoft.module.erpModel.caseErpSale.vo.OutStoreVo;
import com.xjrsoft.module.erpModel.caseErpSale.vo.ProductVo;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

public class DataBuildUtil {

    // 构建销售开票记录
    public static List<InvoiceVo> buildInvoiceLogList(Long saleId) {
        List<InvoiceVo> resultList = new ArrayList<>();
        InvoiceVo invoiceLog1 = new InvoiceVo();
        invoiceLog1.setId(1L);
        invoiceLog1.setSaleId(saleId);
        invoiceLog1.setCode("KP20230110" + RandomUtil.randomNumbers(3));
        invoiceLog1.setTheme("aaaaa");
        invoiceLog1.setDate(LocalDateTime.now());
        invoiceLog1.setInvoiceName("增值税专用发票");
        invoiceLog1.setTicketNum(RandomUtil.randomNumbers(10));
        invoiceLog1.setTicketAmount(new BigDecimal(653.73));
        invoiceLog1.setTicketName("客户一");
        resultList.add(invoiceLog1);

        InvoiceVo invoiceLog2 = new InvoiceVo();
        invoiceLog2.setId(2L);
        invoiceLog2.setSaleId(saleId);
        invoiceLog2.setCode("KP20230112" + RandomUtil.randomNumbers(3));
        invoiceLog2.setTheme("bbbbbb");
        invoiceLog2.setDate(LocalDateTime.now().plusDays(2));
        invoiceLog2.setInvoiceName("增值税专用发票");
        invoiceLog2.setTicketNum(RandomUtil.randomNumbers(10));
        invoiceLog2.setTicketAmount(new BigDecimal(4368.64));
        invoiceLog2.setTicketName("客户二");
        resultList.add(invoiceLog2);

        InvoiceVo invoiceLog3 = new InvoiceVo();
        invoiceLog3.setId(3L);
        invoiceLog3.setSaleId(saleId);
        invoiceLog3.setCode("KP20230111" + RandomUtil.randomNumbers(3));
        invoiceLog3.setTheme("ccccc");
        invoiceLog3.setDate(LocalDateTime.now().plusDays(-4));
        invoiceLog3.setInvoiceName("增值税专用发票");
        invoiceLog3.setTicketNum(RandomUtil.randomNumbers(10));
        invoiceLog3.setTicketAmount(new BigDecimal(2354.10));
        invoiceLog3.setTicketName("客户三");
        resultList.add(invoiceLog3);
        return resultList;
    }

    // 构建销售出库记录
    public static List<OutStoreVo> buildOutStoreLogList(Long saleId) {
        List<OutStoreVo> resultList = new ArrayList<>();

        OutStoreVo outStoreLog1 = new OutStoreVo();
        outStoreLog1.setId(1L);
        outStoreLog1.setSaleId(saleId);
        outStoreLog1.setCode("CK20230111" + RandomUtil.randomNumbers(3));
        outStoreLog1.setTheme("aaaa");
        outStoreLog1.setDate(LocalDateTime.now().plusDays(-3));
        outStoreLog1.setName("客户一");
        outStoreLog1.setCount(new BigDecimal(185));
        outStoreLog1.setPerson("Yongchang Xiong");
        outStoreLog1.setStore("原料库A01");
        resultList.add(outStoreLog1);

        OutStoreVo outStoreLog2 = new OutStoreVo();
        outStoreLog2.setId(2L);
        outStoreLog2.setSaleId(saleId);
        outStoreLog2.setCode("CK20220911" + RandomUtil.randomNumbers(3));
        outStoreLog2.setTheme("bbbb");
        outStoreLog2.setDate(LocalDateTime.now().plusDays(-11));
        outStoreLog2.setName("客户二");
        outStoreLog2.setCount(new BigDecimal(263));
        outStoreLog2.setPerson("Yongchang Xiong");
        outStoreLog2.setStore("原料库A02");
        resultList.add(outStoreLog2);

        OutStoreVo outStoreLog3 = new OutStoreVo();
        outStoreLog3.setId(3L);
        outStoreLog3.setSaleId(saleId);
        outStoreLog3.setCode("CK20230102" + RandomUtil.randomNumbers(3));
        outStoreLog3.setTheme("ccc");
        outStoreLog3.setDate(LocalDateTime.now().plusDays(-22));
        outStoreLog3.setName("客户三");
        outStoreLog3.setCount(new BigDecimal(15));
        outStoreLog3.setPerson("Yongchang Xiong");
        outStoreLog3.setStore("原料库A03");
        resultList.add(outStoreLog3);

        return resultList;
    }

    // 构建销售生产记录
    public static List<ProductVo> buildProductLogList(Long saleId) {
        List<ProductVo> resultList = new ArrayList<>();
        ProductVo productLog1 = new ProductVo();
        productLog1.setId(1L);
        productLog1.setSaleId(saleId);
        productLog1.setCode("CK20230102" + RandomUtil.randomNumbers(3));
        productLog1.setTheme("aaaa");
        productLog1.setType("内部生产");
        productLog1.setDate(LocalDateTime.now().plusDays(-9));
        productLog1.setPerson("李梦");
        productLog1.setDep("生产部一");
        productLog1.setState("未完成");
        resultList.add(productLog1);

        ProductVo productLog2 = new ProductVo();
        productLog2.setId(2L);
        productLog2.setSaleId(saleId);
        productLog2.setCode("CK20230106" + RandomUtil.randomNumbers(3));
        productLog2.setTheme("bbbb");
        productLog2.setType("委派生产");
        productLog2.setDate(LocalDateTime.now().plusDays(-9));
        productLog2.setPerson("李梦");
        productLog2.setDep("生产部二");
        productLog2.setState("完成");
        resultList.add(productLog2);

        ProductVo productLog3 = new ProductVo();
        productLog3.setId(3L);
        productLog3.setSaleId(saleId);
        productLog3.setCode("CK20230104" + RandomUtil.randomNumbers(3));
        productLog3.setTheme("cccc");
        productLog3.setType("内部生产");
        productLog3.setDate(LocalDateTime.now().plusDays(-9));
        productLog3.setPerson("李梦");
        productLog3.setDep("生产部三");
        productLog3.setState("未完成");
        resultList.add(productLog3);
        return resultList;
    }

    // 构建销售收款记录
    public static List<CollectionVo> buildCollectionVoList(Long saleId) {
        List<CollectionVo> resultList = new ArrayList<>();
        CollectionVo collection1 =  new CollectionVo();
        collection1.setId(1L);
        collection1.setCode("SK20230116" + RandomUtil.randomNumbers(3));
        collection1.setTheme("aaaa");
        collection1.setSaleId(saleId);
        collection1.setAmount(new BigDecimal(4368.64));
        collection1.setAccount(RandomUtil.randomNumbers(14));
        collection1.setDate(LocalDateTime.now().plusDays(-13));
        collection1.setPayer("客户10");
        resultList.add(collection1);

        CollectionVo collection2 =  new CollectionVo();
        collection2.setId(2L);
        collection2.setCode("CK20230105" + RandomUtil.randomNumbers(3));
        collection2.setTheme("bbbb");
        collection2.setSaleId(saleId);
        collection2.setAmount(new BigDecimal(1236.23));
        collection2.setAccount(RandomUtil.randomNumbers(14));
        collection2.setDate(LocalDateTime.now().plusDays(-3));
        collection2.setPayer("客户12");
        resultList.add(collection2);

        CollectionVo collection3 =  new CollectionVo();
        collection3.setId(3L);
        collection3.setCode("CK20230113" + RandomUtil.randomNumbers(3));
        collection3.setTheme("cccc");
        collection3.setSaleId(saleId);
        collection3.setAmount(new BigDecimal(23.20));
        collection3.setAccount(RandomUtil.randomNumbers(14));
        collection3.setDate(LocalDateTime.now().plusDays(-5));
        collection3.setPayer("客户06");
        resultList.add(collection3);
        return resultList;
    }
}
